package org.bees.cms.web.util.velocity.element;

import net.sf.json.JSONObject;

import org.bees.cms.common.Transformable;

public abstract class AbstractElement implements Element, Transformable<JSONObject> {
	private static final long serialVersionUID = -4363732416705836255L;

	protected String id = "";
	protected String clazz = "";
	protected String style = "";

	@Override
	public String fromHTML(String html) throws Exception {
		return null;
	}

	@Override
	public String toHTML() throws Exception {
		return null;
	}

	@Override
	public void from(JSONObject t) throws Exception {
		id = t.containsKey("id") ? t.getString("id") : id;
		clazz = t.containsKey("clazz") ? t.getString("clazz") : clazz;
		style = t.containsKey("style") ? t.getString("style") : style;
	}

	@Override
	public JSONObject to() throws Exception {
		JSONObject json = new JSONObject();
		json.accumulate("id", id);
		json.accumulate("clazz", clazz);
		json.accumulate("style", style);
		return json;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getClazz() {
		return clazz;
	}

	public void setClazz(String clazz) {
		this.clazz = clazz;
	}

	public String getStyle() {
		return style;
	}

	public void setStyle(String style) {
		this.style = style;
	}

}